package cn.cloudreal.cbms.mediaPrice.action;

import java.io.IOException;
import java.io.PrintWriter;
import java.net.URLDecoder;
import java.sql.Timestamp;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletResponse;

import org.apache.log4j.Logger;
import org.apache.struts2.ServletActionContext;

import cn.cloudreal.cbms.common.util.Constants;
import cn.cloudreal.cbms.common.util.DatadicContext;
import cn.cloudreal.cbms.common.util.PageBean;
import cn.cloudreal.cbms.common.util.StringUtils;
import cn.cloudreal.cbms.contract.service.ContractListService;
import cn.cloudreal.cbms.levelRule.service.LevelRuleService;
import cn.cloudreal.cbms.log.service.OptLogService;
import cn.cloudreal.cbms.mediaPrice.service.MediaPriceService;
import cn.cloudreal.cbms.mediasumm.service.MediasummService;
import cn.cloudreal.cbms.medium.service.MediumService;
import cn.cloudreal.cbms.vo.CastDetail;
import cn.cloudreal.cbms.vo.Contract;
import cn.cloudreal.cbms.vo.Dictionary;
import cn.cloudreal.cbms.vo.LevelRule;
import cn.cloudreal.cbms.vo.Log;
import cn.cloudreal.cbms.vo.MediaPrice;
import cn.cloudreal.cbms.vo.Mediasumm;
import cn.cloudreal.cbms.vo.Medium;
import cn.cloudreal.cbms.vo.Project;
import cn.cloudreal.cbms.vo.ProjectMedium;
import cn.cloudreal.cbms.vo.UserInfo;

import com.opensymphony.xwork2.ActionSupport;

/**
 * <p>
 * Title: CBM
 * </p>
 * <p>
 * Description:媒体资源库
 * </p>
 * <p>
 * Copyright: Copyright (c) 2012
 * </p>
 * <p>
 * Company:云恒瑞通
 * </p>
 * 
 * @author liupanpan
 * @date 2012-07-09
 */
public class MediaPriceAction extends ActionSupport {
	private OptLogService optLogService = null; // 日志的service
	private List<Log> logList = null;// 列表显示详情日志
	private MediaPriceService mediaPriceService = null; // 媒体价格service
	private ContractListService contractListService = null; // 合同service
	private MediasummService mediasummService = null; // 媒介service
	private MediumService mediumService = null;
	private LevelRuleService levelRuleService = null; // 阶梯service
	private List<MediaPrice> mpList = null;
	private List<Contract> contractList = null;
	private String years;// 年份
	private String mediaName = "";// 媒体名称
	private List<MediaPrice> yearsList = null;
	private String mediaDiscountType = "";
	private String contractName = "";// 合同名称
	private String contractID = "";// 合同编号
	private Contract contract = null; // 合同实体类
	private MediaPrice mediaPrice = null; // 媒体价格类
	private Mediasumm mediasumm = null; // 媒体类
	private String city = "";// 地区
	private String mediaType = "";// 媒体类型
	private List<Dictionary> citylist = new ArrayList<Dictionary>();// 地区list
	private List<Dictionary> mediaDiscountTypeList = null;// 媒体折扣类型
	private List<Dictionary> mediaResourceTypeList = null;// 媒体资源类型
	private List<Dictionary> mediaPurchaseTypeList = null;// 媒体统购类型 MTTGLX
	private List<Dictionary> mediaBelogList = null;// 媒体归属
	private List<Dictionary> mediaTypeList = null;// 媒体类型
	private List<Dictionary> levelCalculatePeriodList = null;// 阶梯计算周期List
	private List<Dictionary> promotionATypeList = null;// 赠送使用类型
	private List<Dictionary> payModeList = null;// 付款方式
	private String message = "";// 返还内容
	private int mediaID = 0;// 媒体编号
	private int priceID = 0;// 媒体价格ID
	private String levelLowerLimit_01 = "";// 随单赠送下限值
	private String levelUpperLimit_01 = "";// 随单赠送上限值
	private String levelDiscount_01 = "";// 随单赠送额度

	private String levelLowerLimit_02 = "";// 常规赠送下限值
	private String levelUpperLimit_02 = "";// 常规赠送上限值
	private String levelDiscount_02 = "";// 常规赠送额度

	private String levelLowerLimit_03 = "";// 返还下限值
	private String levelUpperLimit_03 = "";// 返还上限值
	private String levelDiscount_03 = "";// 返还额度

	private String suiDanSaleType = "";// 随单优惠类型
	private String changGuiSaleType = "";

	private List<LevelRule> suiDanList = null;// 随单阶梯
	private List<LevelRule> changGuiList = null;// 常规阶梯
	private List<LevelRule> fanHuaiList = null;// 返还阶梯

	private int suiDanListSize = 0;// 随单Listsize
	private int changGuiListSize = 0;// 常规Listsize
	private int fanHuaiListSize = 0;// 返还Listsize
	private int falg = 0;// 修改状态跳转
	private double eDuValue = 0;// 返还额度
	private int levelID = 0;// 阶梯档次
	private int mediumListSize = 0;// 媒介是否存在
	private String uploadErrorMessage = "";
	private String noError = "";
	/** 当前页 */
	private int currentPage;

	/** 分页对象 */
	private PageBean page;
	/** 日志工具类实例 */
	private static final Logger log = Logger.getLogger(MediaPriceAction.class);

	/**
	 * 分页查询媒体列表
	 * 
	 * @return string
	 */
	public String findAllMediaPrice() {
		// 打印进入方法体日志
		if (log.isInfoEnabled()) {
			log
					.info("Enter MediaPriceAction findAllMediaPrice() method, return String");
		}
		try {
			if ("".equals(years) || years == null) {
				years = this.getYear();
			}
			yearsList = new ArrayList<MediaPrice>();
			int yeares = Integer.parseInt(this.getYear());
			yeares = yeares + 1;
			for (int i = 0; i < 5; i++) {
				yeares = yeares - 1;
				MediaPrice mediaPrice = new MediaPrice();
				mediaPrice.setContractYear(String.valueOf(yeares));// values
				yearsList.add(mediaPrice);
			}
			MediaPrice mediaPrice = new MediaPrice();
			mediaPrice.setContractYear(years);
			if ("".equals(mediaName)) {
				mediaName = "输入媒体名称";
			} else if ("输入媒体名称".equals(mediaName)) {
				mediaName = "输入媒体名称";
			} else {
				mediaPrice.setPromotionALastValidDate(mediaName); // 媒体名称
			}
			// 获取当前session对象中所属城市
			UserInfo userInfo = (UserInfo) ServletActionContext.getRequest()
					.getSession().getAttribute(Constants.SESSIONPRKEY);
			// 非空
			if (null != userInfo) {
				if (userInfo.getUserRole() != null) {
					// 默认东莞
					String userCity = "DG";
					// 非空重置
					if (userInfo.getUsercity() != null) {
						if (!"".equals(userInfo.getUsercity())) {
							userCity = userInfo.getUsercity();
						}
					}
					// 操作范围
					String roleRange = userInfo.getUserRole().getRoleRange();
					if (roleRange != null) {
						// 省
						if ("1".endsWith(roleRange)) {
							if (city == null || "".equals(city)) {
								city = userCity;
							}
							mediaPrice.setCity(city); // 地区
							mediaPrice.setMediaDiscountType(mediaDiscountType); // 折扣类型
							mediaPrice.setMediaEndTime(mediaType);// 媒体类型
							citylist = DatadicContext.getInstance()
									.getDicDataListByCode("CITY"); // 地市List
							mediaDiscountTypeList = DatadicContext
									.getInstance().getDicDataListByCode(
											"MTZKLX");// 媒体折扣类型
							mediaTypeList = DatadicContext.getInstance()
									.getDicDataListByCode("MTLX");// 媒体类型
							mediaBelogList = DatadicContext.getInstance()
									.getDicDataListByCode("MTGS");// 媒体归属类型LIst
							// 实例化 page分页对象
							page = new PageBean(currentPage == 0 ? 1
									: currentPage, 10);
							mpList = mediaPriceService.findMediaPriceList(page,
									mediaPrice);
						}

						if ("2".endsWith(roleRange)) {
							if (city == null || "".equals(city)) {
								city = userCity;
							}
							Dictionary cityDictionary = DatadicContext
									.getInstance().getDatadicObject(city,
											"CITY");
							if (cityDictionary != null) {
								citylist.add(cityDictionary);
							}
							mediaPrice.setCity(city); // 地区
							mediaPrice.setMediaDiscountType(mediaDiscountType); // 折扣类型
							mediaPrice.setMediaEndTime(mediaType);// 媒体类型
							mediaDiscountTypeList = DatadicContext
									.getInstance().getDicDataListByCode(
											"MTZKLX");// 媒体折扣类型
							mediaTypeList = DatadicContext.getInstance()
									.getDicDataListByCode("MTLX");// 媒体类型
							mediaBelogList = DatadicContext.getInstance()
									.getDicDataListByCode("MTGS");// 媒体归属类型LIst
							// 实例化 page分页对象
							page = new PageBean(currentPage == 0 ? 1
									: currentPage, 10);
							mpList = mediaPriceService.findMediaPriceList(page,
									mediaPrice);
						}

						if ("3".endsWith(roleRange)) {
							if (city == null || "".equals(city)) {
								city = userCity;
							}
							Dictionary cityDictionary = DatadicContext
									.getInstance().getDatadicObject(city,
											"CITY");
							if (cityDictionary != null) {
								citylist.add(cityDictionary);
							}
							mediaPrice.setCity(city); // 地区
							mediaPrice.setMediaDiscountType(mediaDiscountType); // 折扣类型
							mediaPrice.setMediaEndTime(mediaType);// 媒体类型
							mediaDiscountTypeList = DatadicContext
									.getInstance().getDicDataListByCode(
											"MTZKLX");// 媒体折扣类型
							mediaTypeList = DatadicContext.getInstance()
									.getDicDataListByCode("MTLX");// 媒体类型
							mediaBelogList = DatadicContext.getInstance()
									.getDicDataListByCode("MTGS");// 媒体归属类型LIst
							// 实例化 page分页对象
							page = new PageBean(currentPage == 0 ? 1
									: currentPage, 10);
							mpList = mediaPriceService.findMediaPriceList(page,
									mediaPrice);
						}
					}
				}
			}
		} catch (Exception e) {
			// 打印异常信息
			e.printStackTrace();
			// 打印异常方法体日志
			if (log.isInfoEnabled()) {
				log
						.error(
								"Exception MediaPriceAction findAllMediaPrice() method",
								e);
			}
			return ERROR;
		}
		// 打印退出方法体日志
		if (log.isInfoEnabled()) {
			log
					.info("Exit MediaPriceAction findAllMediaPrice() method, return String");
		}
		return SUCCESS;
	}

	/**
	 * 跳转到添加媒体页面
	 * 
	 * @return
	 */
	public String toAddMediasumm() {
		// 打印进入方法体日志
		if (log.isInfoEnabled()) {
			log
					.info("Enter MediaPriceAction toAddMediasumm() method, return String");
		}
		try {
			// 获取当前session对象中所属城市
			UserInfo userInfo = (UserInfo) ServletActionContext.getRequest()
					.getSession().getAttribute(Constants.SESSIONPRKEY);
			SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd");
			Date date = new Date();
			Contract contract1 = new Contract();
			contract1.setContractYear(this.getYear());
			contract1.setContractCity(userInfo.getUsercity());
			contract1.setContractStartTime(sf.format(date));// 开始时间
			contract1.setContractEndTime(sf.format(date));// 结束时间
			contractList = contractListService.findContractByYears(contract1);
			mediaTypeList = DatadicContext.getInstance().getDicDataListByCode(
					"MTLX");// 媒体类型
			mediaDiscountTypeList = DatadicContext.getInstance()
					.getDicDataListByCode("MTZKLX");// 媒体折扣类型
			mediaResourceTypeList = DatadicContext.getInstance()
					.getDicDataListByCode("MTZYLX");// 媒体资源类型List
			mediaPurchaseTypeList = DatadicContext.getInstance()
					.getDicDataListByCode("MTTGLX");// 媒体统购类型LIst
			mediaBelogList = DatadicContext.getInstance().getDicDataListByCode(
					"MTGS");// 媒体归属类型LIst
			levelCalculatePeriodList = DatadicContext.getInstance()
					.getDicDataListByCode("MTJTJSZQ");// 阶梯计算周期
			promotionATypeList = DatadicContext.getInstance()
					.getDicDataListByCode("ZSSYLX");// 赠送使用类型
			mediaPrice = new MediaPrice();
			mediaPrice.setMediaStartTime(sf.format(date));// 当天
			SimpleDateFormat sf1 = new SimpleDateFormat("yyyy");
			String nextYear = String
					.valueOf(Integer.parseInt(sf1.format(date)) + 1);
			SimpleDateFormat sf2 = new SimpleDateFormat("MM-dd");
			String nextYears = nextYear + "-" + sf2.format(date);
			mediaPrice.setMediaEndTime(nextYears); // 当天
		} catch (Exception e) {
			e.printStackTrace();
			return ERROR;
		}
		// 打印退出方法体日志
		if (log.isInfoEnabled()) {
			log
					.info("Exit MediaPriceAction toAddMediasumm() method, return String");
		}
		return SUCCESS;
	}

	/**
	 * 根据合同名称查询
	 * 
	 * @return
	 */
	public String findAllMediasummByName() {
		// 打印进入方法体日志
		if (log.isInfoEnabled()) {
			log
					.info("Enter MediaPriceAction findAllMediasummByName() method, return String");
		}
		try {
			UserInfo userInfo = (UserInfo) ServletActionContext.getRequest()
					.getSession().getAttribute(Constants.SESSIONPRKEY);
			SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd");
			Date date = new Date();
			Contract contract1 = new Contract();
			contract1.setContractYear(this.getYear());
			contract1.setContractName(contractName.trim());
			contract1.setContractCity(userInfo.getUsercity());
			contract1.setContractStartTime(sf.format(date));// 开始时间
			contract1.setContractEndTime(sf.format(date));// 结束时间
			contractList = contractListService.findContractByYears(contract1);
		} catch (Exception e) {
			return ERROR;
		}
		// 打印进入方法体日志
		if (log.isInfoEnabled()) {
			log
					.info("Exit MediaPriceAction findAllMediasummByName() method, return String");
		}
		return SUCCESS;
	}

	/**
	 * 根据合同编号查询
	 */
	public String findAllMediasummByID() {
		// 打印进入方法体日志
		if (log.isInfoEnabled()) {
			log
					.info("Enter MediaPriceAction findAllMediasummByID() method, return String");
		}
		try {
			Contract contract1 = new Contract();
			contract1.setContractYear(this.getYear());
			contract1.setContractID(contractID);
			contractList = contractListService.findContractByYears(contract1);
			citylist = DatadicContext.getInstance()
					.getDicDataListByCode("CITY"); // 地市List
			mediaPurchaseTypeList = DatadicContext.getInstance()
					.getDicDataListByCode("MTTGLX");// 媒体统购类型LIst
			payModeList = DatadicContext.getInstance().getDicDataListByCode(
					"FKFS"); // 付款方式List
			if (contractList != null) {
				contract = contractList.get(0);
				// System.out.println(contract.getContractID());
			}

		} catch (Exception e) {
			e.printStackTrace();
			return ERROR;
		}
		// 打印进入方法体日志
		if (log.isInfoEnabled()) {
			log
					.info("Exit MediaPriceAction findAllMediasummByID() method, return String");
		}
		return SUCCESS;
	}

	/**
	 * 根据媒体编号查询
	 * 
	 * @return
	 */
	public String findMediaPriceByMediaID() {
		// 打印进入方法体日志
		if (log.isInfoEnabled()) {
			log
					.info("Enter MediaPriceAction findMediaPriceByMediaID() method, return String");
		}
		try {
			UserInfo userInfo = (UserInfo) ServletActionContext.getRequest()
					.getSession().getAttribute(Constants.SESSIONPRKEY);
			String city = userInfo.getUsercity();// 归属地市
			List<MediaPrice> list = mediaPriceService
					.findMediaPriceByMediaIDOrName(mediaID, "", "", city);
			if (list != null && list.size() != 0) {
				message = "error";
			} else {
				message = "success";
			}
		} catch (Exception e) {
			e.printStackTrace();
			return ERROR;
		}
		// 打印进入方法体日志
		if (log.isInfoEnabled()) {
			log
					.info("Exit MediaPriceAction findMediaPriceByMediaID() method, return String");
		}
		return SUCCESS;
	}

	/**
	 * 根据媒体名称查询
	 * 
	 * @return
	 */

	public String findMediaPriceBymediaName() {
		// 打印进入方法体日志
		if (log.isInfoEnabled()) {
			log
					.info("Enter MediaPriceAction findMediaPriceBymediaName() method, return String");
		}
		try {
			SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd");
			Date date = new Date();
			String nowDate = sf.format(date);
			UserInfo userInfo = (UserInfo) ServletActionContext.getRequest()
					.getSession().getAttribute(Constants.SESSIONPRKEY);
			String city = userInfo.getUsercity();// 归属地市
			String mediaName1 = URLDecoder.decode(mediaName.trim(), "UTF-8");
			System.out.println(mediaName1);
			List<MediaPrice> list = mediaPriceService
					.findMediaPriceByMediaIDOrName_01(mediaName1, city, null);
			if (list != null && list.size() != 0) {
				message = "error";
			} else {
				message = "success";
			}
		} catch (Exception e) {
			e.printStackTrace();
			return ERROR;
		}
		// 打印进入方法体日志
		if (log.isInfoEnabled()) {
			log
					.info("Exit MediaPriceAction findMediaPriceBymediaName() method, return String");
		}
		return SUCCESS;
	}

	/**
	 * AJAX 根据媒体价格ID查找媒体
	 * 
	 * @return
	 */
	public String findMediaPriceByPriceID() {
		List<MediaPrice> list = mediaPriceService
				.findAllMediaPriceByPriceID(priceID);
		if (list != null && list.size() != 0) {
			mediaPrice = list.get(0);
			// System.out.println(mediaPrice.getMediasumm().getMediaName());
		}
		return SUCCESS;
	}

	/**
	 * 添加项目
	 * 
	 * @return
	 */
	public String doAddMediasumm() {
		// 打印进入方法体日志
		if (log.isInfoEnabled()) {
			log
					.info("Enter MediaPriceAction doAddMediasumm() method, return String");
		}
		int priceID_01 = 0;// 媒体价格ID
		int mediaID_01 = 0;// 媒体ID
		try {
			if (mediasumm != null) {
				mediaPrice.setMediaID(mediasumm.getMediaID()); // 媒体编号
			}
			mediaID_01 = mediasummService.addMediasumm(mediasumm); // 添加媒体表
			mediaPrice.setMediaID(mediaID_01);
			priceID_01 = mediaPriceService.addMediaPrice(mediaPrice); // 添加媒体价格表

			if (!"".equals(levelLowerLimit_01)) {
				// 随单赠送 阶梯额度类型2
				String[] levelLowerLimit_01Arr = levelLowerLimit_01.split(",");
				String[] levelUpperLimit_01Arr = levelUpperLimit_01.split(",");
				String[] levelDiscount_01Arr = levelDiscount_01.split(",");
				for (int i = 0; i < levelLowerLimit_01Arr.length; i++) {
					LevelRule levelRule = new LevelRule();
					for (int j = 0; j <= i; j++) {
						if (!"0".equals(levelUpperLimit_01Arr[j])) {
							levelRule
									.setLevelUpperLimit_01(String
											.valueOf(Double
													.parseDouble(levelUpperLimit_01Arr[j]) * 10000));// 阶梯上限值
						} else {
							levelRule
									.setLevelUpperLimit_01(String
											.valueOf(Double
													.parseDouble("100000") * 10000));// 上限最大值
						}
					}
					if ("1".equals(suiDanSaleType)) {
						for (int j = 0; j <= i; j++) {
							levelRule.setLevelDiscount(Double
									.parseDouble(levelDiscount_01Arr[j]));// 阶梯额度
						}
					}
					if ("2".equals(suiDanSaleType)) {
						for (int j = 0; j <= i; j++) {
							levelRule.setLevelDiscount(Double
									.parseDouble(levelDiscount_01Arr[j]));// 阶梯额度
						}
					}
					levelRule.setPriceID(priceID_01); // 阶梯价格ID
					levelRule.setLevelLowerLimit(Double
							.parseDouble(levelLowerLimit_01Arr[i]) * 10000);// 阶梯下限值
					levelRule.setMediaID(mediaID_01);// 媒体编号
					levelRule.setContractYear(mediaPrice.getContractYear());// 合同签订年份
					levelRule.setLevelID(i + 1);// 随单阶梯编号
					levelRule.setLevelPromotionType(suiDanSaleType);// 阶梯类型
					levelRule.setSaleType("2");// 优惠类型

					// 添加阶梯 随单赠送
					levelRuleService.addLevelRule(levelRule);
					// System.out.println(levelRule.getLevelLowerLimit() + "___"
					// + levelRule.getLevelUpperLimit()
					// + "___" + levelRule.getLevelDiscount());
				}
			}

			if (!"".equals(levelLowerLimit_02)) {
				// 常规赠送 阶梯额度类型3
				String[] levelLowerLimit_02Arr = levelLowerLimit_02.split(",");
				String[] levelUpperLimit_02Arr = levelUpperLimit_02.split(",");
				String[] levelDiscount_02Arr = levelDiscount_02.split(",");
				for (int i = 0; i < levelLowerLimit_02Arr.length; i++) {
					LevelRule levelRule = new LevelRule();
					for (int j = 0; j <= i; j++) {
						if (!"0".equals(levelUpperLimit_02Arr[j])) {
							levelRule
									.setLevelUpperLimit_01(String
											.valueOf(Double
													.parseDouble(levelUpperLimit_02Arr[j]) * 10000));// 阶梯上限值
						} else {
							levelRule
									.setLevelUpperLimit_01(String
											.valueOf(Double
													.parseDouble("100000") * 10000));// 上限最大值
						}
					}
					if ("1".equals(changGuiSaleType)) {
						for (int j = 0; j <= i; j++) {
							levelRule.setLevelDiscount(Double
									.parseDouble(levelDiscount_02Arr[j]));// 阶梯额度
						}
					}
					if ("2".equals(changGuiSaleType)) {
						for (int j = 0; j <= i; j++) {
							levelRule.setLevelDiscount(Double
									.parseDouble(levelDiscount_02Arr[j]));// 阶梯额度
						}
					}
					levelRule.setPriceID(priceID_01); // 阶梯价格ID
					levelRule.setLevelLowerLimit(Double
							.parseDouble(levelLowerLimit_02Arr[i]) * 10000);// 阶梯下限值
					levelRule.setMediaID(mediasumm.getMediaID());// 媒体编号
					levelRule.setContractYear(mediaPrice.getContractYear());// 合同签订年份
					levelRule.setLevelID(i + 1);// 常规阶梯编号
					levelRule.setLevelPromotionType(changGuiSaleType);// 阶梯类型
					levelRule.setSaleType("3");// 优惠类型

					// 添加阶梯 常规赠送
					levelRuleService.addLevelRule(levelRule);
					// System.out.println(levelRule.getLevelLowerLimit()+"___"+levelRule.getLevelUpperLimit()+"___"+levelRule.getLevelDiscount());
				}
			}
			if (!"".equals(levelLowerLimit_03)) {
				// 返还 阶梯额度类型1
				String[] levelLowerLimit_03Arr = levelLowerLimit_03.split(",");
				String[] levelUpperLimit_03Arr = levelUpperLimit_03.split(",");
				String[] levelDiscount_03Arr = levelDiscount_03.split(",");
				for (int i = 0; i < levelLowerLimit_03Arr.length; i++) {
					LevelRule levelRule = new LevelRule();
					for (int j = 0; j <= i; j++) {
						if (!"0".equals(levelUpperLimit_03Arr[j])) {
							levelRule
									.setLevelUpperLimit_01(String
											.valueOf(Double
													.parseDouble(levelUpperLimit_03Arr[j]) * 10000));// 阶梯上限值
						} else {
							levelRule
									.setLevelUpperLimit_01(String
											.valueOf(Double
													.parseDouble("100000") * 10000));// 上限最大值
						}
					}
					for (int j = 0; j <= i; j++) {
						levelRule.setLevelDiscount(Double
								.parseDouble(levelDiscount_03Arr[j]));// 阶梯额度
					}
					levelRule.setPriceID(priceID_01); // 阶梯价格ID
					levelRule.setLevelLowerLimit(Double
							.parseDouble(levelLowerLimit_03Arr[i]) * 10000);// 阶梯下限值
					levelRule.setMediaID(mediasumm.getMediaID());// 媒体编号
					levelRule.setContractYear(mediaPrice.getContractYear());// 合同签订年份
					levelRule.setLevelID(i + 1);// 返还阶梯编号
					levelRule.setLevelPromotionType("1");// 阶梯类型
					levelRule.setSaleType("1");// 优惠类型

					// 添加阶梯 返还赠送
					levelRuleService.addLevelRule(levelRule);
				}
			} else if (eDuValue > 0) {
				LevelRule levelRule = new LevelRule();
				levelRule.setPriceID(priceID_01); // 阶梯价格ID
				levelRule.setLevelLowerLimit(Double.parseDouble("0"));// 阶梯下限值
				levelRule.setLevelUpperLimit_01(String.valueOf(Double
						.parseDouble("100000") * 10000));// 阶梯上限值
				levelRule.setMediaID(mediasumm.getMediaID());// 媒体编号
				levelRule.setContractYear(mediaPrice.getContractYear());// 合同签订年份
				levelRule.setLevelID(0);// 返还阶梯编号
				levelRule.setLevelPromotionType("1");// 阶梯类型(折扣)
				levelRule.setLevelDiscount(eDuValue);// 额度
				levelRule.setSaleType("1");// 优惠类型
				levelRuleService.addLevelRule(levelRule);// 添加
			}
			levelLowerLimit_01 = "";
			levelLowerLimit_02 = "";
			levelLowerLimit_02 = "";
			if (falg == 1) {// 跳转到增加媒介页面
				if (priceID_01 == 0) {
					return ERROR;
				} else {
					this
							.alertMessage("媒体新增成功",
									"toAddMediumAction.action?priceID="
											+ priceID_01 + "&mediaID="
											+ mediaPrice.getMediaID()
											+ "&contractYear="
											+ mediaPrice.getContractYear()
											+ "&mediaType1="
											+ mediasumm.getMediaType());
				}
			}
			if (falg == 2) {// 跳转到媒体列表
				this.alertMessage("媒体新增成功",
						"mediaPriceAction.action?currentPage=1");
			}
			// 详情日志
			this.findLogMessage("新增了", "媒体", "T_CB_MEDIAPRICE", String
					.valueOf(priceID_01));

		} catch (Exception e) {
			e.printStackTrace();
			return ERROR;
		}

		// 打印进入方法体日志
		if (log.isInfoEnabled()) {
			log
					.info("Exit MediaPriceAction doAddMediasumm() method, return String");
		}
		return null;
	}

	/**
	 * 删除媒体
	 */
	public String delMediaById() {
		// 打印进入方法体日志
		if (log.isInfoEnabled()) {
			log
					.info("Enter MediaPriceAction delMediaById() method, return String");
		}
		try {
			// response 对象
			HttpServletResponse response = ServletActionContext.getResponse();
			// 获取PrintWriter对象
			ServletActionContext.getRequest().setCharacterEncoding(
					Constants.STR_UTF);
			response.setContentType(Constants.STR_CHARSET);
			PrintWriter out = null;
			out = response.getWriter();
			List<Medium> mList = mediumService.findMediumByMediaID(mediaID);
			if (mList != null && mList.size() != 0) {
				out.print("error");
			} else {
				// 删除媒体和媒体价格，阶梯
				levelRuleService.delLevelRuleByPriceID_01(priceID);// 先删除阶梯
				mediaPriceService.delMediaPrice(priceID, mediaID);// 再删媒体单价
				int num = mediasummService.delMediasumm(mediaID);// 先删媒体
				out.print("success");
			}
		} catch (Exception e) {
			e.printStackTrace();
			return ERROR;
		}
		// 详情日志
		this.findLogMessage("删除了", "媒体,媒体编号：" + mediaID, "T_CB_MEDIAPRICE",
				String.valueOf(priceID));
		if (log.isInfoEnabled()) {
			log
					.info("Exit MediaPriceAction delMediaById() method, return String");
		}
		return null;
	}

	/**
	 * 媒体详情
	 * 
	 * @return
	 */
	public String toMediumDetail() {
		// 打印进入方法体日志
		if (log.isInfoEnabled()) {
			log
					.info("Enter MediaPriceAction toMediumDetail() method, return String");
		}
		try {
			List<MediaPrice> list = mediaPriceService
					.findMediaPriceByPriceID(priceID);
			if (list != null && list.size() != 0) {
				for (int i = 0; i < list.size(); i++) {
					mediaPrice = list.get(i);
				}
			}
			if (mediaPrice == null) {
				return "error_01";
			}
			citylist = DatadicContext.getInstance()
					.getDicDataListByCode("CITY"); // 地市List
			mediaTypeList = DatadicContext.getInstance().getDicDataListByCode(
					"MTLX");// 媒体类型
			mediaDiscountTypeList = DatadicContext.getInstance()
					.getDicDataListByCode("MTZKLX");// 媒体折扣类型
			mediaResourceTypeList = DatadicContext.getInstance()
					.getDicDataListByCode("MTZYLX");// 媒体资源类型List
			mediaPurchaseTypeList = DatadicContext.getInstance()
					.getDicDataListByCode("MTTGLX");// 媒体统购类型LIst
			mediaBelogList = DatadicContext.getInstance().getDicDataListByCode(
					"MTGS");// 媒体归属类型LIst
			levelCalculatePeriodList = DatadicContext.getInstance()
					.getDicDataListByCode("MTJTJSZQ");// 阶梯计算周期
			promotionATypeList = DatadicContext.getInstance()
					.getDicDataListByCode("ZSSYLX");// 赠送使用类型
			payModeList = DatadicContext.getInstance().getDicDataListByCode(
					"FKFS"); // 付款方式List
			// 阶梯2 随单
			suiDanList = levelRuleService.findLevelRuleByPriceIDAndType(
					priceID, "2");
			// 阶梯3 常规
			changGuiList = levelRuleService.findLevelRuleByPriceIDAndType(
					priceID, "3");
			// 阶梯1 返还
			fanHuaiList = levelRuleService.findLevelRuleByPriceIDAndType(
					priceID, "1");
			if (fanHuaiList.size() != 0) {
				eDuValue = fanHuaiList.get(0).getLevelDiscount();// 额度
				levelID = fanHuaiList.get(0).getLevelID();// 阶梯档次
			}
			// 日志详情
			Log sample = new Log();
			sample.setRelationId(String.valueOf(mediaPrice.getPriceID()));
			sample.setLogType("T_CB_MEDIAPRICE");
			logList = new ArrayList<Log>();
			logList = optLogService.getLogsBySample(sample);
		} catch (Exception e) {
			e.printStackTrace();
			return ERROR;
		}
		if (log.isInfoEnabled()) {
			log
					.info("Exit MediaPriceAction toMediumDetail() method, return String");
		}
		return SUCCESS;
	}

	/**
	 * 跳转到媒体修改页面
	 * 
	 * @return
	 */
	public String toUpdateMedia() {
		// 开始打印日志
		if (log.isInfoEnabled()) {
			log
					.info("Enter MediaPriceAction toUpdateMedia() method, return String");
		}
		try {
			// 获取当前session对象中所属城市
			UserInfo userInfo = (UserInfo) ServletActionContext.getRequest()
					.getSession().getAttribute(Constants.SESSIONPRKEY);
			SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd");
			Date date = new Date();
			Contract contract1 = new Contract();
			contract1.setContractYear(this.getYear());
			contract1.setContractCity(userInfo.getUsercity());
			contract1.setContractStartTime(sf.format(date));// 开始时间
			contract1.setContractEndTime(sf.format(date));// 结束时间
			citylist = DatadicContext.getInstance()
					.getDicDataListByCode("CITY"); // 地市List
			contractList = contractListService.findContractByYears(contract1);
			mediaTypeList = DatadicContext.getInstance().getDicDataListByCode(
					"MTLX");// 媒体类型
			mediaDiscountTypeList = DatadicContext.getInstance()
					.getDicDataListByCode("MTZKLX");// 媒体折扣类型
			mediaResourceTypeList = DatadicContext.getInstance()
					.getDicDataListByCode("MTZYLX");// 媒体资源类型List
			mediaPurchaseTypeList = DatadicContext.getInstance()
					.getDicDataListByCode("MTTGLX");// 媒体统购类型LIst
			mediaBelogList = DatadicContext.getInstance().getDicDataListByCode(
					"MTGS");// 媒体归属类型LIst
			levelCalculatePeriodList = DatadicContext.getInstance()
					.getDicDataListByCode("MTJTJSZQ");// 阶梯计算周期
			promotionATypeList = DatadicContext.getInstance()
					.getDicDataListByCode("ZSSYLX");// 赠送使用类型
			payModeList = DatadicContext.getInstance().getDicDataListByCode(
					"FKFS"); // 付款方式List

			if (mediaPriceService.findMediaPriceByPriceID(priceID) == null
					|| mediaPriceService.findMediaPriceByPriceID(priceID)
							.size() == 0) {
				return "error_01";
			} else {
				mediaPrice = mediaPriceService.findMediaPriceByPriceID(priceID)
						.get(0);
			}
			List<Medium> mList = mediumService.findMediumByMediaID(mediaPrice
					.getMediaID());
			if (mList != null && mList.size() != 0) {
				mediumListSize = mList.size();
			} else {
				mediumListSize = 0;
			}
			// 阶梯2 随单
			suiDanList = levelRuleService.findLevelRuleByPriceIDAndType(
					priceID, "2");
			if (suiDanList != null && suiDanList.size() != 0) {
				suiDanSaleType = suiDanList.get(0).getLevelPromotionType();
			} else {
				suiDanSaleType = "1";
			}
			// 阶梯3 常规
			changGuiList = levelRuleService.findLevelRuleByPriceIDAndType(
					priceID, "3");
			if (changGuiList != null && changGuiList.size() != 0) {
				changGuiSaleType = changGuiList.get(0).getLevelPromotionType();
			} else {
				changGuiSaleType = "1";
			}
			// 阶梯1 返还
			fanHuaiList = levelRuleService.findLevelRuleByPriceIDAndType(
					priceID, "1");
			if (suiDanList != null && suiDanList.size() != 0) {
				suiDanListSize = suiDanList.size();
			}
			if (changGuiList != null && changGuiList.size() != 0) {
				changGuiListSize = changGuiList.size();
			}
			if (fanHuaiList.size() != 0) {
				fanHuaiListSize = fanHuaiList.size();
				eDuValue = fanHuaiList.get(0).getLevelDiscount();// 额度
				levelID = fanHuaiList.get(0).getLevelID();// 阶梯档次
			}
		} catch (Exception e) {
			e.printStackTrace();
			return ERROR;
		}
		// 结束打印日志
		if (log.isInfoEnabled()) {
			log
					.info("Exit MediaPriceAction toUpdateMedia() method, return String");
		}
		return SUCCESS;
	}

	/**
	 * 修改媒体信息
	 */
	public String doUpdateMedia() {
		// 开始打印日志
		if (log.isInfoEnabled()) {
			log
					.info("Enter MediaPriceAction doUpdateMedia() method, return String");
		}
		try {
			// 修改媒体
			mediasummService.updateMediasumm(mediasumm);
			// 修改媒体价格
			mediaPrice.setMediaID(mediasumm.getMediaID());// 媒体编号
			mediaPriceService.updateMediaPrice(mediaPrice);

			// 删除阶梯并增加阶梯
			if (!"".equals(levelLowerLimit_01)) {
				// 删除随单阶梯2
				levelRuleService.delLevelRuleByPriceID(mediaPrice.getPriceID(),
						"2");
				// 随单赠送 阶梯额度类型2
				String[] levelLowerLimit_01Arr = levelLowerLimit_01.split(",");
				String[] levelUpperLimit_01Arr = levelUpperLimit_01.split(",");
				String[] levelDiscount_01Arr = levelDiscount_01.split(",");
				for (int i = 0; i < levelLowerLimit_01Arr.length; i++) {
					LevelRule levelRule = new LevelRule();
					for (int j = 0; j <= i; j++) {
						// System.out.println(levelUpperLimit_01Arr[j]+"__"+j);
						if (!"0".equals(levelUpperLimit_01Arr[j])) {
							levelRule
									.setLevelUpperLimit_01(String
											.valueOf(Double
													.parseDouble(levelUpperLimit_01Arr[j]) * 10000));// 阶梯上限值
						} else {
							levelRule
									.setLevelUpperLimit_01(String
											.valueOf(Double
													.parseDouble("100000") * 10000));// 上限最大值
						}
					}
					if ("1".equals(suiDanSaleType)) {
						for (int j = 0; j <= i; j++) {
							levelRule.setLevelDiscount(Double
									.parseDouble(levelDiscount_01Arr[j]));// 阶梯额度
						}
					}
					if ("2".equals(suiDanSaleType)) {
						for (int j = 0; j <= i; j++) {
							levelRule.setLevelDiscount(Double
									.parseDouble(levelDiscount_01Arr[j]));// 阶梯额度
						}
					}
					levelRule.setPriceID(mediaPrice.getPriceID()); // 阶梯价格ID
					levelRule.setLevelLowerLimit(Double
							.parseDouble(levelLowerLimit_01Arr[i]) * 10000);// 阶梯下限值
					levelRule.setMediaID(mediasumm.getMediaID());// 媒体编号
					levelRule.setContractYear(mediaPrice.getContractYear());// 合同签订年份
					levelRule.setLevelID(i + 1);// 随单阶梯编号
					levelRule.setLevelPromotionType(suiDanSaleType);// 阶梯类型
					levelRule.setSaleType("2");
					// 添加阶梯 随单赠送
					levelRuleService.addLevelRule(levelRule);
					// System.out.println(levelRule.getLevelLowerLimit() + "___"
					// + levelRule.getLevelUpperLimit() + "___"
					// + levelRule.getLevelDiscount());
				}
			} else {
				// 删除随单阶梯2
				levelRuleService.delLevelRuleByPriceID(mediaPrice.getPriceID(),
						"2");
			}

			// 删除常规赠送3
			if (!"".equals(levelLowerLimit_02)) {
				// 删除常规 阶梯额度类型3
				levelRuleService.delLevelRuleByPriceID(mediaPrice.getPriceID(),
						"3");
				// 常规赠送 阶梯额度类型3
				String[] levelLowerLimit_02Arr = levelLowerLimit_02.split(",");
				String[] levelUpperLimit_02Arr = levelUpperLimit_02.split(",");
				String[] levelDiscount_02Arr = levelDiscount_02.split(",");
				for (int i = 0; i < levelLowerLimit_02Arr.length; i++) {
					LevelRule levelRule = new LevelRule();
					for (int j = 0; j <= i; j++) {
						if (!"0".equals(levelUpperLimit_02Arr[j])) {
							levelRule
									.setLevelUpperLimit_01(String
											.valueOf(Double
													.parseDouble(levelUpperLimit_02Arr[j]) * 10000));// 阶梯上限值
						} else {
							levelRule
									.setLevelUpperLimit_01(String
											.valueOf(Double
													.parseDouble("100000") * 10000));// 上限最大值
						}
					}
					if ("1".equals(changGuiSaleType)) {
						for (int j = 0; j <= i; j++) {
							levelRule.setLevelDiscount(Double
									.parseDouble(levelDiscount_02Arr[j]));// 阶梯额度
						}
					}
					if ("2".equals(changGuiSaleType)) {
						for (int j = 0; j <= i; j++) {
							levelRule.setLevelDiscount(Double
									.parseDouble(levelDiscount_02Arr[j]));// 阶梯额度
						}
					}
					levelRule.setPriceID(mediaPrice.getPriceID()); // 阶梯价格ID
					levelRule.setLevelLowerLimit(Double
							.parseDouble(levelLowerLimit_02Arr[i]) * 10000);// 阶梯下限值
					levelRule.setMediaID(mediasumm.getMediaID());// 媒体编号
					levelRule.setContractYear(mediaPrice.getContractYear());// 合同签订年份
					levelRule.setLevelID(i + 1);// 常规阶梯编号
					levelRule.setLevelPromotionType(changGuiSaleType);// 阶梯类型
					levelRule.setSaleType("3");

					// 添加阶梯 常规赠送
					levelRuleService.addLevelRule(levelRule);
					// System.out.println(levelRule.getLevelLowerLimit()+"___"+levelRule.getLevelUpperLimit()+"___"+levelRule.getLevelDiscount());
				}
			} else {
				// 删除常规 阶梯额度类型3
				levelRuleService.delLevelRuleByPriceID(mediaPrice.getPriceID(),
						"3");
			}

			// 删除返还阶梯1
			if (!"".equals(levelLowerLimit_03)) {
				// 删除返还阶梯 阶梯额度类型1
				levelRuleService.delLevelRuleByPriceID(mediaPrice.getPriceID(),
						"1");
				// 返还 阶梯额度类型1
				String[] levelLowerLimit_03Arr = levelLowerLimit_03.split(",");
				String[] levelUpperLimit_03Arr = levelUpperLimit_03.split(",");
				String[] levelDiscount_03Arr = levelDiscount_03.split(",");
				for (int i = 0; i < levelLowerLimit_03Arr.length; i++) {
					LevelRule levelRule = new LevelRule();
					for (int j = 0; j <= i; j++) {
						if (!"0".equals(levelUpperLimit_03Arr[j])) {
							levelRule
									.setLevelUpperLimit_01(String
											.valueOf(Double
													.parseDouble(levelUpperLimit_03Arr[j]) * 10000));// 阶梯上限值
						} else {
							levelRule
									.setLevelUpperLimit_01(String
											.valueOf(Double
													.parseDouble("100000") * 10000));// 上限最大值
						}
					}
					for (int j = 0; j <= i; j++) {
						levelRule.setLevelDiscount(Double
								.parseDouble(levelDiscount_03Arr[j]));// 阶梯额度
					}
					levelRule.setPriceID(mediaPrice.getPriceID()); // 阶梯价格ID
					levelRule.setLevelLowerLimit(Double
							.parseDouble(levelLowerLimit_03Arr[i]) * 10000);// 阶梯下限值
					levelRule.setMediaID(mediasumm.getMediaID());// 媒体编号
					levelRule.setContractYear(mediaPrice.getContractYear());// 合同签订年份
					levelRule.setLevelID(i + 1);// 返还阶梯编号
					levelRule.setLevelPromotionType("1");// 阶梯类型
					levelRule.setSaleType("1");
					// 添加阶梯 返还赠送
					levelRuleService.addLevelRule(levelRule);
					// System.out.println(levelRule.getLevelLowerLimit()+"___"+levelRule.getLevelUpperLimit_01()+"___"+levelRule.getLevelDiscount());
				}
			} else {
				// 删除返还阶梯 阶梯额度类型1
				levelRuleService.delLevelRuleByPriceID(mediaPrice.getPriceID(),
						"1");
			}
			if (eDuValue > 0) {
				LevelRule levelRule = new LevelRule();
				levelRule.setPriceID(mediaPrice.getPriceID()); // 阶梯价格ID
				levelRule.setLevelLowerLimit(Double.parseDouble("0"));// 阶梯下限值
				levelRule.setLevelUpperLimit_01(String.valueOf(Double
						.parseDouble("100000") * 10000));// 阶梯上限值
				levelRule.setMediaID(mediasumm.getMediaID());// 媒体编号
				levelRule.setContractYear(mediaPrice.getContractYear());// 合同签订年份
				levelRule.setLevelID(0);// 返还阶梯编号
				levelRule.setLevelPromotionType("1");// 阶梯类型
				levelRule.setLevelDiscount(eDuValue);// 额度
				levelRule.setSaleType("1");
				levelRuleService.addLevelRule(levelRule);// 添加
			} else {
				// 删除返还阶梯 阶梯额度类型1
				levelRuleService.delLevelRuleByPriceID(mediaPrice.getPriceID(),
						"0");
			}

			// 详情日志
			this.findLogMessage("编辑了", "媒体", "T_CB_MEDIAPRICE", String
					.valueOf(mediaPrice.getPriceID()));

			levelLowerLimit_01 = "";
			levelLowerLimit_02 = "";
			levelLowerLimit_02 = "";
			this
					.alertMessage("媒体修改成功",
							"mediaPriceAction.action?currentPage=1");
		} catch (Exception e) {
			e.printStackTrace();
			return ERROR;
		}

		// 结束打印日志
		if (log.isInfoEnabled()) {
			log
					.info("Exit MediaPriceAction toUpdateMedia() method, return String");
		}
		return null;
	}

	/**
	 * 弹出提示信息
	 */
	private void alertMessage(String message, String url) {
		try {
			HttpServletResponse response = ServletActionContext.getResponse();
			response.setCharacterEncoding("UTF-8");
			response.setContentType("text/html; charset=utf-8");
			PrintWriter out = response.getWriter();
			out = response.getWriter();
			out.println(" <script type='text/javascript' >");
			out.println("alert('" + message + "');");
			out.println("location='" + url + "'");
			out.println(" </script>");
			out.flush();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

	/**
	 * 返回当前年月日
	 * 
	 * @return
	 */
	public String getYear() {
		java.text.SimpleDateFormat df = new java.text.SimpleDateFormat("yyyy");
		Calendar c = Calendar.getInstance();
		c.set(c.DATE, 1);
		return df.format(c.getTime());
	}

	// 获取日志
	public void findLogMessage(String addOrUpdateMsg, String typeName,
			String tableName, String tableID) {
		// 日志记录
		UserInfo userSession = (UserInfo) ServletActionContext.getRequest()
				.getSession().getAttribute("logUser");
		String user = null;
		String cityCode = null;
		String cityName = null;
		String organizaOragName = null;
		if (null == userSession) {
			user = "张三";
			cityName = "东莞";
			organizaOragName = "市场部";
			cityCode = "DG";
		} else {
			user = userSession.getUserName();
			cityCode = userSession.getUsercity();
			cityName = userSession.getCityName();
			organizaOragName = userSession.getOrganiza().getOrgName();
		}
		if (null == cityCode) {
			cityCode = "";
			cityName = "东莞";
		}
		Timestamp d = new Timestamp(System.currentTimeMillis());
		String content = d + " " + cityName + organizaOragName + user
				+ addOrUpdateMsg + typeName;
		String datatime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS")
				.format(new Date());
		// System.out.println("data======"+data);
		/** 获取变更记录的数据 */
		Log logRecord = new Log(tableName, content, tableID, datatime, user,
				cityCode, organizaOragName, "");
		optLogService.addLog(logRecord);
	}

	public String getLevelLowerLimit_02() {
		return levelLowerLimit_02;
	}

	public void setLevelLowerLimit_02(String levelLowerLimit_02) {
		this.levelLowerLimit_02 = levelLowerLimit_02;
	}

	public String getLevelUpperLimit_02() {
		return levelUpperLimit_02;
	}

	public void setLevelUpperLimit_02(String levelUpperLimit_02) {
		this.levelUpperLimit_02 = levelUpperLimit_02;
	}

	public String getLevelDiscount_02() {
		return levelDiscount_02;
	}

	public void setLevelDiscount_02(String levelDiscount_02) {
		this.levelDiscount_02 = levelDiscount_02;
	}

	public String getLevelLowerLimit_03() {
		return levelLowerLimit_03;
	}

	public void setLevelLowerLimit_03(String levelLowerLimit_03) {
		this.levelLowerLimit_03 = levelLowerLimit_03;
	}

	public String getLevelUpperLimit_03() {
		return levelUpperLimit_03;
	}

	public void setLevelUpperLimit_03(String levelUpperLimit_03) {
		this.levelUpperLimit_03 = levelUpperLimit_03;
	}

	public String getLevelDiscount_03() {
		return levelDiscount_03;
	}

	public void setLevelDiscount_03(String levelDiscount_03) {
		this.levelDiscount_03 = levelDiscount_03;
	}

	public int getCurrentPage() {
		return currentPage;
	}

	public void setCurrentPage(int currentPage) {
		this.currentPage = currentPage;
	}

	public PageBean getPage() {
		return page;
	}

	public void setPage(PageBean page) {
		this.page = page;
	}

	public List<MediaPrice> getMpList() {
		return mpList;
	}

	public void setMpList(List<MediaPrice> mpList) {
		this.mpList = mpList;
	}

	public String getYears() {
		return years;
	}

	public void setYears(String years) {
		this.years = years;
	}

	public List<MediaPrice> getYearsList() {
		return yearsList;
	}

	public void setYearsList(List<MediaPrice> yearsList) {
		this.yearsList = yearsList;
	}

	public String getMediaName() {
		return mediaName;
	}

	public void setMediaName(String mediaName) {
		this.mediaName = mediaName;
	}

	public List<Dictionary> getMediaResourceTypeList() {
		return mediaResourceTypeList;
	}

	public void setMediaResourceTypeList(List<Dictionary> mediaResourceTypeList) {
		this.mediaResourceTypeList = mediaResourceTypeList;
	}

	public List<Dictionary> getMediaPurchaseTypeList() {
		return mediaPurchaseTypeList;
	}

	public void setMediaPurchaseTypeList(List<Dictionary> mediaPurchaseTypeList) {
		this.mediaPurchaseTypeList = mediaPurchaseTypeList;
	}

	public String getMediaDiscountType() {
		return mediaDiscountType;
	}

	public void setMediaDiscountType(String mediaDiscountType) {
		this.mediaDiscountType = mediaDiscountType;
	}

	public void setMediaPriceService(MediaPriceService mediaPriceService) {
		this.mediaPriceService = mediaPriceService;
	}

	public void setContractListService(ContractListService contractListService) {
		this.contractListService = contractListService;
	}

	public List<Contract> getContractList() {
		return contractList;
	}

	public void setContractList(List<Contract> contractList) {
		this.contractList = contractList;
	}

	public String getContractName() {
		return contractName;
	}

	public void setContractName(String contractName) {
		this.contractName = contractName;
	}

	public String getContractID() {
		return contractID;
	}

	public void setContractID(String contractID) {
		this.contractID = contractID;
	}

	public Contract getContract() {
		return contract;
	}

	public void setContract(Contract contract) {
		this.contract = contract;
	}

	public MediaPrice getMediaPrice() {
		return mediaPrice;
	}

	public void setMediaPrice(MediaPrice mediaPrice) {
		this.mediaPrice = mediaPrice;
	}

	public Mediasumm getMediasumm() {
		return mediasumm;
	}

	public void setMediasumm(Mediasumm mediasumm) {
		this.mediasumm = mediasumm;
	}

	public String getCity() {
		return city;
	}

	public void setCity(String city) {
		this.city = city;
	}

	public List<Dictionary> getCitylist() {
		return citylist;
	}

	public void setCitylist(List<Dictionary> citylist) {
		this.citylist = citylist;
	}

	public void setMediasummService(MediasummService mediasummService) {
		this.mediasummService = mediasummService;
	}

	public void setLevelRuleService(LevelRuleService levelRuleService) {
		this.levelRuleService = levelRuleService;
	}

	public List<Dictionary> getMediaDiscountTypeList() {
		return mediaDiscountTypeList;
	}

	public void setMediaDiscountTypeList(List<Dictionary> mediaDiscountTypeList) {
		this.mediaDiscountTypeList = mediaDiscountTypeList;
	}

	public void setMediumService(MediumService mediumService) {
		this.mediumService = mediumService;
	}

	public int getMediaID() {
		return mediaID;
	}

	public void setMediaID(int mediaID) {
		this.mediaID = mediaID;
	}

	public int getPriceID() {
		return priceID;
	}

	public void setPriceID(int priceID) {
		this.priceID = priceID;
	}

	public String getLevelLowerLimit_01() {
		return levelLowerLimit_01;
	}

	public void setLevelLowerLimit_01(String levelLowerLimit_01) {
		this.levelLowerLimit_01 = levelLowerLimit_01;
	}

	public String getLevelUpperLimit_01() {
		return levelUpperLimit_01;
	}

	public void setLevelUpperLimit_01(String levelUpperLimit_01) {
		this.levelUpperLimit_01 = levelUpperLimit_01;
	}

	public String getLevelDiscount_01() {
		return levelDiscount_01;
	}

	public void setLevelDiscount_01(String levelDiscount_01) {
		this.levelDiscount_01 = levelDiscount_01;
	}

	public List<Dictionary> getMediaTypeList() {
		return mediaTypeList;
	}

	public void setMediaTypeList(List<Dictionary> mediaTypeList) {
		this.mediaTypeList = mediaTypeList;
	}

	public String getMediaType() {
		return mediaType;
	}

	public void setMediaType(String mediaType) {
		this.mediaType = mediaType;
	}

	public String getMessage() {
		return message;
	}

	public void setMessage(String message) {
		this.message = message;
	}

	public List<Dictionary> getMediaBelogList() {
		return mediaBelogList;
	}

	public void setMediaBelogList(List<Dictionary> mediaBelogList) {
		this.mediaBelogList = mediaBelogList;
	}

	public List<LevelRule> getSuiDanList() {
		return suiDanList;
	}

	public void setSuiDanList(List<LevelRule> suiDanList) {
		this.suiDanList = suiDanList;
	}

	public List<LevelRule> getChangGuiList() {
		return changGuiList;
	}

	public void setChangGuiList(List<LevelRule> changGuiList) {
		this.changGuiList = changGuiList;
	}

	public List<LevelRule> getFanHuaiList() {
		return fanHuaiList;
	}

	public void setFanHuaiList(List<LevelRule> fanHuaiList) {
		this.fanHuaiList = fanHuaiList;
	}

	public List<Dictionary> getLevelCalculatePeriodList() {
		return levelCalculatePeriodList;
	}

	public void setLevelCalculatePeriodList(
			List<Dictionary> levelCalculatePeriodList) {
		this.levelCalculatePeriodList = levelCalculatePeriodList;
	}

	public List<Dictionary> getPromotionATypeList() {
		return promotionATypeList;
	}

	public void setPromotionATypeList(List<Dictionary> promotionATypeList) {
		this.promotionATypeList = promotionATypeList;
	}

	public int getSuiDanListSize() {
		return suiDanListSize;
	}

	public void setSuiDanListSize(int suiDanListSize) {
		this.suiDanListSize = suiDanListSize;
	}

	public int getChangGuiListSize() {
		return changGuiListSize;
	}

	public void setChangGuiListSize(int changGuiListSize) {
		this.changGuiListSize = changGuiListSize;
	}

	public int getFanHuaiListSize() {
		return fanHuaiListSize;
	}

	public void setFanHuaiListSize(int fanHuaiListSize) {
		this.fanHuaiListSize = fanHuaiListSize;
	}

	public int getFalg() {
		return falg;
	}

	public void setFalg(int falg) {
		this.falg = falg;
	}

	public int getLevelID() {
		return levelID;
	}

	public void setLevelID(int levelID) {
		this.levelID = levelID;
	}

	public List<Log> getLogList() {
		return logList;
	}

	public void setLogList(List<Log> logList) {
		this.logList = logList;
	}

	public void setOptLogService(OptLogService optLogService) {
		this.optLogService = optLogService;
	}

	public String getSuiDanSaleType() {
		return suiDanSaleType;
	}

	public void setSuiDanSaleType(String suiDanSaleType) {
		this.suiDanSaleType = suiDanSaleType;
	}

	public String getChangGuiSaleType() {
		return changGuiSaleType;
	}

	public void setChangGuiSaleType(String changGuiSaleType) {
		this.changGuiSaleType = changGuiSaleType;
	}

	public int getMediumListSize() {
		return mediumListSize;
	}

	public void setMediumListSize(int mediumListSize) {
		this.mediumListSize = mediumListSize;
	}

	public List<Dictionary> getPayModeList() {
		return payModeList;
	}

	public void setPayModeList(List<Dictionary> payModeList) {
		this.payModeList = payModeList;
	}

	public String getUploadErrorMessage() {
		return uploadErrorMessage;
	}

	public void setUploadErrorMessage(String uploadErrorMessage) {
		this.uploadErrorMessage = uploadErrorMessage;
	}

	public double getEDuValue() {
		return eDuValue;
	}

	public void setEDuValue(double duValue) {
		eDuValue = duValue;
	}

	public String getNoError() {
		return noError;
	}

	public void setNoError(String noError) {
		this.noError = noError;
	}

	public static void main(String[] args) {
		java.text.SimpleDateFormat df = new java.text.SimpleDateFormat("yyyy");
		Calendar c = Calendar.getInstance();
		c.set(c.DATE, 1);
		int years = Integer.parseInt(df.format(c.getTime()));
		years = years + 1;
		List<Integer> yearsList = new ArrayList<Integer>();
		for (int i = 0; i < 5; i++) {
			years = years - 1;
			yearsList.add(years);
		}

		for (int i = 0; i < yearsList.size(); i++) {
			System.out.println(yearsList.get(i));
		}

	}

}
